package leetcode;

public class RemoveDuplicates {

    public int removeDuplicates(int[] nums){
        int count = nums.length;
        for(int i = 0; i < count - 1; i++){
            int sameCount = 0;
            for(int j = i; j < count - 1; j++){
                if(nums[j] == nums[j + 1]){
                    sameCount++;
                }else{
                    break;
                }
            }
            count -= sameCount;
            for(int j = i + 1; j < count; j++){
                nums[j] = nums[j + sameCount];
            }
        }
        return count;
    }

    public static void main(String[] args) {
        int[] arr = {0,0,1,1,1,2,2,3,3,4};
        new RemoveDuplicates().removeDuplicates(arr);
    }

}
